package com.hllxd.hism.star.basic.service.service;

import com.alibaba.fastjson.JSON;
import com.hllxd.hism.star.basic.service.dao.mapper.mis.HelpdocMapper;
import com.hllxd.hism.star.basic.service.model.HelpdocEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 系统升级功能管理
 * @author xiyong.lxy
 * @date 2020-10-12 16:51
 */
@Slf4j
@Service("helpdocService")
public class HelpdocServiceImpl implements HelpdocService {

    @Autowired
    private HelpdocMapper helpdocMapper;


    @Override public HelpdocEntity getHelpdoc(Long id) {
        return helpdocMapper.getHelpdoc(id);
    }

    @Override
    public Long setHelpdoc(HelpdocEntity entity) {
        log.info("set param: {}", JSON.toJSONString(entity));
        if(entity.id==null || entity.id==0) {
            log.info("will insert entity.");
            entity.action = 0;
            return helpdocMapper.insertHelpdoc(entity);
        } else {
            log.info("will update entity.");
            if(entity.action == null) {
                entity.action = 1;
            }
            return helpdocMapper.updateHelpdoc(entity);
        }
    }

    @Override
    public List<HelpdocEntity> listHelpdoc() {
        return helpdocMapper.listHelpdoc();
    }

    @Override
    public Boolean deleteHelpdoc(String ids) {
        return helpdocMapper.deleteHelpdoc(ids);
    }
}
